package com.chatdating.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chatdating.entity.Like;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface LikeMapper extends BaseMapper<Like> {
    @Select("SELECT COUNT(*) FROM likes WHERE post_id = #{postId}")
    int countByPostId(Long postId);

    @Delete("DELETE FROM likes WHERE post_id = #{postId} AND user_id = #{userId}")
    int deleteByPostAndUser(@Param("postId") Long postId, @Param("userId") Integer userId);
}
